<template>
  <div class="app-container">
      <el-form
        ref="dataForm"
        :model="temp"
        :rules="rules"
        label-position="right"
        label-width="150px"
        style="width: 700px; margin:0 auto;margin-top:5%"
      >
        <el-form-item label="签到说明描述:" prop="description">
          <el-input placeholder="请输入签到规则说明" type="textarea" v-model="temp.description" />
        </el-form-item>
        <el-form-item label="跳转功能页面:" prop="dictVal">
            <el-select
                placeholder="请选择"
                clearable
                class="filter-item"
                style="width: 300px"
                v-model="temp.dictVal"
            >
                <el-option v-for="item in pageList" :key="item.val" :label="item.k" :value="item.val"/>
            </el-select > 
        </el-form-item>
      </el-form>
      <el-button
        size="medium"
        class="filter-item"
        type="success"
        style="display:block;margin:0 auto"
        @click="signIn"
      >
        保存并发布
      </el-button>
  </div>
</template>

<script>
// 异步请求 delLly
import Vue from 'vue'
import { getData,findPage,update } from '@/api/messagepush/index'

export default {
  inject:["reload"],
  data() {
    return {
      temp: {
      },
      pageList:[],
      rules:{
          dictVal:[{
              required: true, message: '不能为空'
          }],
          description:[{
              required: true, message: '不能为空'
          }],
      }
    }
  },
  created() {
    this.getList()
    this.getPage()
  },
  methods: {
    getList(){
        var params={
          pageSize:10,
          pageNum:0
        }
        getData(params).then(res=>{
            this.temp=res.data.content[0]
        })
    },
    //查询页面数组
    getPage(){
      findPage().then(res=>{
        this.pageList=res
      })
    },
    //编辑
    signIn(){
        update(this.temp).then(res=>{
            if(res.code==='200'){
              this.$notify({
                  title: '成功',
                  message: '修改成功',
                  type: 'success',
                  duration: 4000
              })
              this.reload()
            }else{
              this.$notify({
                  title: '失败',
                  message: '修改失败',
                  type: 'danger',
                  duration: 4000
              })
              this.reload()
            }
        })
    }
  }
}
</script>
<style>
</style>
